package com.yz.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

/**
 * @author yuanzheng
 * @date 2020/7/24-13:10
 */
@Controller
public class UserLoginController {
    @RequestMapping("/user/login")
    public String login(@RequestParam("userName") String userName,
                        @RequestParam("password") String password,
                        Model model,
                        HttpSession session) {
        if (!StringUtils.isEmpty(userName) && "123".equals(password)) {
            //return "dashboard";
            session.setAttribute("userName",userName);
            return "redirect:/main.html";
        } else {
            model.addAttribute("msg", "账号或密码有误！");
            return "index";
        }
    }
}
